using System;
using System.Collections.Generic;
using System.Text;
using Garlic.CC.Utility;


namespace Garlic.CC.BaseClass
{
    public class UserUtil
    {
        /// <summary>
        /// Get Current User
        /// </summary>
        /// <returns></returns>
		public static IUser GetCurrentUser()
        {
            if (System.Web.HttpContext.Current == null)
            {
                return new AnonymousUser();
            }
            else
            {
                if (System.Web.HttpContext.Current.Session[BasePage.SessionKey_CurrentUser] == null)
                {
                    throw new AuthenticationException();
                }
                return (IUser)(System.Web.HttpContext.Current.Session[BasePage.SessionKey_CurrentUser]);
            }
        }
    }

	public class AnonymousUser : IUser
    {
        #region IUser Members

        public int UserID
        {
            get
            {
                return -1;
            }
            set
            {
                
            }
        }

        public string AccountName
        {
            get
            {
                return "Anonymous";
            }
            set
            {
               
            }
        }

        public string Password
        {
            get
            {
                return "";
            }
            set
            {
                
            }
        }

        public string UserType
        {
            get
            {
                return "";
            }
            set
            {
                
            }
        }

        public string EmployeeName
        {
            get
            {
                return "Anonymous";
            }
            set
            {
               
            }
        }

        public string Email
        {
            get
            {
                return "Anonymous@XY.com";
            }
            set
            {
               
            }
        }

        public string Mobile
        {
            get
            {
                return "";
            }
            set
            {
               
            }
        }

        public string OfficePhone
        {
            get
            {
                return "";
            }
            set
            {
               
            }
        }

        public UserStatus Status
        {
            get
            {
                return UserStatus.Stop;
            }
            set
            {
               
            }
        }

        public DateTime CreateTime
        {
            get
            {
                return DateTime.Now;
            }
            set
            {
               
            }
        }

        public IUser CreateUser
        {
            get
            {
                return null;
            }
            set
            {
               
            }
        }

        public DateTime ModifyTime
        {
            get
            {
                return DateTime.Now; 
            }
            set
            {
               
            }
        }

        public DateTime PasswordExpireTime
        {
            get
            {
                return DateTime.Now;
            }
            set
            {

            }
        }

        public IUser ModifyUser
        {
            get
            {
                return null;
            }
            set
            {
               
            }
        }

        public List<string> Roles
        {
            get
            {
                return null;
            }
            set
            {
               
            }
        }

        public List<IUserResource> RightList
        {
            get
            {
                return null;
            }
            set
            {
                
            }
        }

        #endregion
    }
}
